#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 110;

int n;
int dp[N][N];

int main()
{
    memset(dp, 0x3f, sizeof dp);
    cin >> n;
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 1; j <= n; j ++)
        {
            cin >> dp[i][j];
            if (i == 1 && j == 1) continue;
            dp[i][j] += min(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    cout << dp[n][n] << endl;
    return 0;
}